package com.example.admin.service;


import com.example.xo.pojo.Category;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@SpringBootTest
@Slf4j
public class CategoryServiceTset {
    @Autowired
    private  CategoryService categoryService;

    @Test
    public void addTest(){
        Category category=new Category();
        category.setCategoryName("范木钦我能十七张牌秒你");
        categoryService.add(category);
    }
    @Test
    public void findAllTest(){
        //将service 的findAll的方法封装成集合
        List<Category> all = categoryService.findAll();
        //遍历集合结果
        for (Category category : all) {
            log.info("查询结果{}",category);
        }

    }
    @Test
    public void findById(){
        Category byId = categoryService.findById("1585977937747238912");
        log.info("查询id{}",byId);
    }
    @Test
    public void deleteByIdTest(){

        boolean b = categoryService.deleteById("1586169302334468096");
        log.info("{}",b);
    }
    @Test
    public void updateTest(){
        Category category=new Category();
        category.setCategoryId("1585977937747238912");
        category.setCategoryName("十七张牌");
        boolean update = categoryService.update(category);
        log.info("{}",update);
    }
}
